package com.intellagric.controller.portal.traceability.trace_table;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.pojo.TraceTableRows;
import com.intellagric.service.traceability.trace_record_table.TableRowsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2019/2/21
 * @DESC： 表格列数据服务接口
 */
@Controller
public class TableRowsController {

    @Autowired
    private TableRowsService tableRowsService;

    /**
     * 添加表格列数据信息
     * @Param tableRows
     * @return ResponseMessage
     */
    @RequestMapping("/table/rows/add")
    @ResponseBody
    public ResponseMessage add(TraceTableRows tableRows) {
        return tableRowsService.addTableRows(tableRows);
    }


    /**
     * 删除表格列数据信息
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/table/rows/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return tableRowsService.deleteTableRows(id);
    }

    /**
     * 修改表格列数据信息
     * @Param
     * @return ResponseMessage
     */
    @RequestMapping("/table/rows/edit")
    @ResponseBody
    public ResponseMessage edit(TraceTableRows tableRows) {
        return tableRowsService.editTableRows(tableRows);
    }

    /**
     * 查询表格列数据信息
     * @return LayuiDataGridResult
     */
    @RequestMapping("/table/rows/list/{tableId}")
    @ResponseBody
    public LayuiDataGridResult get(@PathVariable String tableId) {
        return tableRowsService.getTableRowsBytableId(tableId);
    }

}
